<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="java.text.*"%>
<%@ page import="com.sinodata.bsm.common.vo.PropertyValue"%>
<%
List<PropertyValue> list = (List<PropertyValue>) request.getAttribute("valueList");
String propId = (String)request.getAttribute("propId");
String resId = (String)request.getAttribute("resId");
String  currentval = (String) request.getAttribute("currentval");
SimpleDateFormat ff = new SimpleDateFormat("HH");
String category="";
String val = "";
String max = "";

for(PropertyValue  propVal: list){
    category+="<category label='"+ff.format(propVal.getTime())+"时' />";
    val+="<set value='"+propVal.getValues()[0]+"' />";
    max+="<set value='"+propVal.getValues()[2]+"' />";
}
String str="<?xml version='1.0' encoding='GBK'?>";
str+="<chart showNames='0'   showLimits='1' showLegend='0' canvasBorderThickness='1'";
str+=" showDivLineValue='1' showTickMarks='0'  lineThickness='1' showValues='0' ";
str+=" formatNumberScale='0' anchorRadius='1'   divLineAlpha='20' divLineColor='CC3300'";
str+=" divLineIsDashed='1' showAlternateHGridColor='1' alternateHGridAlpha='5' alternateHGridColor='CC3300'";
str+=" shadowAlpha='40' labelStep='1' numvdivlines='4'  numDivLines='4' chartTopMargin='5' chartBottomMargin='5'";
str+=" chartLeftMargin='5' chartRightMargin='5' bgColor='FFFFFF,CC3300' bgAngle='270' bgAlpha='10,10'>";
str+="<categories>";
str+=category;
str+="</categories>";
str+="<dataset seriesName='平均值' color='1D8BD1' anchorBorderColor='1D8BD1' anchorBgColor='1D8BD1'>";
str+=val;
str+="</dataset>";
str+="<dataset seriesName='最大值' color='8BBA00' anchorBorderColor='1D8BD1' anchorBgColor='1D8BD1'>";
str+=max;
str+="</dataset>";
if(currentval!=null){
	str+=" <trendlines>";
	str+=" <line startValue='"+currentval+"' isTrendZone='0'  color='FF0000'  dashed='1' dashGap='5'/>";
	str+=" </trendlines>";
}
str+="</chart>";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>tooltip.jsp</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<style>
	.a-title{
		color:#888;
	}
</style>

</head>
<body>
	<a href="#" onclick="changeIt(1)" style="float:left; color:#888" class="a-title">时汇聚</a>
	<a href="#" onclick="changeIt(2)" style="float:left; color:#888;margin-left:12px;" class="a-title">日汇聚</a>   
	<a href="#" onclick="closeIt();" style="float:right; color:#666;" class="a-title">[关闭] </a>
	<div id="cpuHis" style="margin-top:4px;">
<script type="text/javascript">
	function changeIt(tt){
		$.ajax({
			type:'post',
			url:'../performance/prop-value!tooltip2.action',
			data:{id:'<%=resId%>', propId:'<%=propId%>', type:tt},
			global:false,
			async:false,
			cache:false,
			dataType:'json',
			success:function(data,textStatus){
				createChart(data,tt);
			}
		});	
		}
	function createChart(values,type)
	{
		var category="";
		var val = "";
		var max = "";
		var list = values.propValues;
		for(var i=0; i<list.length; i++){
			var propVal = list[i];
			if(type==1){
			 category+=" <category label='"+propVal.time.hours+"时' ></category>";
			}else{
			 category+=" <category label='"+propVal.time.day+"天' ></category>";
			}
		    val+=" <set value='"+propVal.values[0]+"' />";
		    max+=" <set value='"+propVal.values[2]+"' />";
		}
	
		var str="<?xml version='1.0' encoding='GBK'?>";
		str+="<chart showNames='0'   showLimits='1' showLegend='0' canvasBorderThickness='1'";
		str+=" showDivLineValue='1' showTickMarks='0'  lineThickness='1' showValues='0' ";
		str+=" formatNumberScale='0' anchorRadius='1'   divLineAlpha='20' divLineColor='CC3300'";
		str+=" divLineIsDashed='1' showAlternateHGridColor='1' alternateHGridAlpha='5' alternateHGridColor='CC3300'";
		str+=" shadowAlpha='40' labelStep='1' numvdivlines='4'  numDivLines='4' chartTopMargin='5' chartBottomMargin='5'";
		str+=" chartLeftMargin='5' chartRightMargin='5' bgColor='FFFFFF,CC3300' bgAngle='270' bgAlpha='10,10'>";
		str+="<categories>";
		str+=category;
		str+="</categories>";
		str+="<dataset seriesName='平均值' color='1D8BD1' anchorBorderColor='1D8BD1' anchorBgColor='1D8BD1'>";
		str+=val;
		str+="</dataset>";
		str+="<dataset seriesName='最大值' color='8BBA00' anchorBorderColor='1D8BD1' anchorBgColor='1D8BD1'>";
		str+=max;
		str+="</dataset>";
		currentval = values.currentval;
		if(currentval!=null){
			str+=" <trendlines>";
			str+=" <line startValue='"+currentval+"' isTrendZone='0'  color='FF0000'  dashed='1' dashGap='5'></line>";
			str+=" </trendlines>";
		}
		str+="</chart>";
	
		var t = new Date().getMilliseconds();
		cpuHisLine =  new FusionCharts("${pageContext.request.contextPath}/resources/charts/MSLine.swf", "cpuHisLine"+t, "280", "120", "0", "1" );
		cpuHisLine.setDataXML(str);
		cpuHisLine.render("cpuHis");
	}
	var xml = "<%=str%>";
		try{
			var t = new Date().getMilliseconds();
			cpuHisLine =  new FusionCharts("${pageContext.request.contextPath}/resources/charts/MSLine.swf", "cpuHisLine"+t, "270", "120", "0", "1" );
			cpuHisLine.setDataXML(xml);
			cpuHisLine.render("cpuHis");
		}catch(e){}
		function closeIt(){
		
			$(document).trigger('hideCluetip');
		}			
</script>
	</div>
	
	</body>
</html>	
